const CompressionPlugin = require('compression-webpack-plugin');
module.exports = {

    filenameHashing: true,

    productionSourceMap: false,
    configureWebpack: config => {
        if (process.env.NODE_ENV === 'production') {
            config.optimization.minimizer[0].options.terserOptions.compress.warnings = false;
            config.optimization.minimizer[0].options.terserOptions.compress.drop_console = true;
            config.optimization.minimizer[0].options.terserOptions.compress.drop_debugger = true;
            config.optimization.minimizer[0].options.terserOptions.compress.pure_funcs = ['console.log'];
            return {
                plugins: [
                    new CompressionPlugin(
                        {
                            test: /\.js$|\.html$|\.css$|\.jpg$|\.jpeg$|\.png/, // 需要压缩的文件类型
                            threshold: 500, // 归档需要进行压缩的文件大小最小值
                            deleteOriginalAssets: false
                        })
                ]
            }
        }
    },
    // webpack-dev-server 相关配置
    devServer: {
        // 设置热替换
        disableHostCheck: true,//webpack4.0 开启热更新
        // 设置页面引入
        inline: false,
        port: 5901,
        // https: false,
        open: false,
        proxy: {
            "/api": {
                target: 'http://10.20.23.137:8000',
                pathRewrite: {
                    "^/api": "/"
                },
                changeOrigin: true,
                ws: true,
            }
        },
    },
    lintOnSave: 'warning',
}


